package com.itheima.health.utils;
import org.springframework.util.DigestUtils;

/**
 * @author ：sean
 * @date ：Created in 2022/5/31
 * @description ：
 * @version: 1.0
 */
public class PasswordUtils {
    public static boolean checkPassword(String password,String dbPassword){
        if(DigestUtils.md5DigestAsHex(password.getBytes()).equals(dbPassword)){
            // 如果是Md5密码
            String mdPassword = DigestUtils.md5DigestAsHex(password.getBytes());
            return mdPassword.equals(dbPassword.replace("{md5}",""));
        }
        // 未加密
        return password.equals(dbPassword);
    }
}
